#include "widget.h"
#include "ui_widget.h"

#include <QPainter>
#include <QPixmap>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    (void) event;
    //创建绘画者
    QPainter painter(this);

    //创建图片对象
    QPixmap pixmap(":/anime.jpeg");

    //基础绘画图片
    //painter.drawPixmap(0,0,pixmap);

    //图片缩放
    //painter.drawPixmap(100,100,400,300,pixmap);

    //图片旋转: 本质上是把QPainter对象进行了旋转,绘制出来的内容也就产生了旋转
    painter.rotate(180);
    painter.translate(-800,-600);   //平移坐标原点
    painter.drawPixmap(100,100,400,300,pixmap);

}

